package com.tac.service.mes.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tac.common.result.Result;
import com.tac.dao.mes.InspectionDao;
import com.tac.pojo.mes.Inspection;
import com.tac.service.mes.InspectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class InspectionServiceImpl implements InspectionService {
    @Autowired
    private InspectionDao inspectionDao;

    //产品检验查询
    public Result<PageInfo<Inspection>> getList(Integer pageNum,Integer pageSize,String serialNumber, String completionOrder, String planNumber, String jobName,
                          String materialName, String inspectionLot, Date produceDateStart, Date produceDateEnd,
                          String inspectionItems, String inspectionResults, String inspector,
                          Date inspectionTimeStart, Date inspectionTimeEnd){
        PageHelper.startPage(pageNum,pageSize);
        List<Inspection> list = inspectionDao.getList(serialNumber, completionOrder, planNumber, jobName, materialName, inspectionLot, produceDateStart, produceDateEnd, inspectionItems, inspectionResults, inspector, inspectionTimeStart, inspectionTimeEnd);
        PageInfo<Inspection> inspectionPageInfo = new PageInfo<>(list);
        return Result.success(inspectionPageInfo);
    }
    //产品检验添加
    public Result save(Inspection inspection){
        Integer integer = inspectionDao.save(inspection);
           if(integer<=0){
               return Result.error("产品检验添加失败");
           }
           return Result.success(null);
    }
    //产品检验删除
    public Result remove(List<Integer> ids){
        Integer integer = inspectionDao.remove(ids);
        if(integer<=0){
            return Result.error("产品检验删除失败");
        }
        return Result.success(null);
    }
    //产品检验更新
    public Result update(Inspection inspection){
        Integer integer = inspectionDao.update(inspection);
        if(integer<=0){
            return Result.error("产品检验更新失败");
        }
        return Result.success(null);
    }
}
